<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>宿舍房间详情</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-4">
  <h2>宿舍房间详情</h2>

  <div class="card">
    <div class="card-body">
      <h5 class="card-title" th:text="${dormRoom.building.buildingName} + ' - ' + ${dormRoom.roomNumber}"></h5>
      <p class="card-text">
        <strong>类型:</strong> <span th:text="${dormRoom.type.typeName}"></span><br>
        <strong>当前人数:</strong> <span th:text="${dormRoom.currentCapacity}"></span><br>
        <strong>最大容量:</strong> <span th:text="${dormRoom.maxCapacity}"></span><br>
        <strong>状态:</strong> <span th:text="${dormRoom.status}"></span>
      </p>

      <h5 class="mt-4">入住学生</h5>
      <table class="table" th:if="${not #lists.isEmpty(dormRoom.students)}">
        <thead>
        <tr>
          <th>学号</th>
          <th>姓名</th>
          <th>学院</th>
          <th>专业</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="student : ${dormRoom.students}">
          <td th:text="${student.studentId}"></td>
          <td th:text="${student.user.realName}"></td>
          <td th:text="${student.college.collegeName}"></td>
          <td th:text="${student.major.majorName}"></td>
        </tr>
        </tbody>
      </table>
      <div th:if="${#lists.isEmpty(dormRoom.students)}" class="alert alert-info">
        当前没有学生入住此房间
      </div>

      <a th:href="@{/dormrooms/list}" class="btn btn-primary">返回列表</a>
    </div>
  </div>
</div>
</body>
</html>